package com.ruoyi.mall.product.spring.init;
import com.ruoyi.mall.product.spring.cache.AppCache;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Component
@Order(value = 1)
//TODO  CommandLineRunner可以理解为开机自启动 用order进行排序
public class AppRunner implements CommandLineRunner {

    private static final Logger LOGGER = LoggerFactory.getLogger(AppRunner.class);

    @Autowired
    private AppCache appCache;

    @Override
    public void run(String... args) {
        LOGGER.info(">>>>>>>>>>>>>>>服务启动执行，执行加载应用信息操作<<<<<<<<<<<<<");

        try {
            //TODO 把appCache装配到启动类  暂时不用这个缓存，用redis
//            appCache.refresh();
        } catch (Exception e) {
            LOGGER.error("应用信息获取失败！！请保证应用配置系统正常启动！");
            e.printStackTrace();
        }
    }
}
